<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.sql.*,java.io.*,java.util.*,java.text.*,java.net.*"%>
<%@ page import="com.ce.util.*"%>
<%@ page import="java.awt.image.*"%>
<%@ page import="javax.imageio.*"%>
<%
try{out.clearBuffer();System.out.println(out.getClass().getName());
	if(false){
		StringBuffer url = new StringBuffer(request.getContextPath()).append("/loadImage.jsp?1=1");
		Enumeration e = request.getParameterNames();
		String par = null;
		while(e.hasMoreElements()){
			par = (String)e.nextElement();
			if(par!=null)
				url.append("&").append(par).append("=").append(request.getParameter(par));
		}
		response.sendRedirect(url.toString());
	}
	else{
	//
	
	//====================================================原有显示图片代码========================================	
		String fileId = (String)request.getParameter("vcId");
		String w = request.getParameter("width");
		String h = request.getParameter("height");
		int width=-1,height=-1;
		try{
			width = Integer.parseInt(w);
		}catch(Exception e){}
		try{
			height = Integer.parseInt(h);
		}catch(Exception e){}
		Connection con = null;
		try{
			con = DbUtil.getConnection();
		    InputStream bis = null;
		    OutputStream bos = new BufferedOutputStream(response.getOutputStream());
		    try{
				String sqlStr = "select  VC_ID,VC_FILENAME,VC_CHILD$FOLDER  from pub_t_file_upload_log t WHERE VC_ID ='" + fileId + "'";
				Statement st = con.createStatement();
				ResultSet rs = st.executeQuery(sqlStr);
				String fileName = null,childFolder=null;
				while (rs.next()) {
					fileId = rs.getString(1);
					fileName = rs.getString(2);
					childFolder = rs.getString(3);
					if(childFolder==null)childFolder="";
					break;
				}
				rs.close();
				bis = NetFileUtil.getImage(childFolder,fileId,width,height);
			    response.setContentType("application/jpeg"); // MIME type for pdf doc
			    response.setHeader("Content-disposition","attachment; filename=\"" + URLEncoder.encode(fileName,"UTF-8") + "\"");
			    
		        byte[] buff = new byte[2048];
		        int bytesRead;
		        bytesRead = bis.read(buff, 0, buff.length);
		        while (bytesRead>=0){
		            try{bos.write(buff, 0, bytesRead);}catch(Exception e){
		            //e.printStackTrace();
		            };
		            bytesRead = bis.read(buff, 0, buff.length);
		        }
			    
		        if (bis != null)
		            bis.close();
		        if (bos != null)
		            bos.close();
		    }
		    catch(FileNotFoundException e ){
		    	//e.printStackTrace();
		    }
		}catch(Exception e){
			//e.printStackTrace();
			throw e;
		}finally{
			if(con!=null)con.close();
		}
	}
}
catch(Throwable ta){
	ta.printStackTrace();
}
//==========================================原有显示图片代码结束====================================*/
%>